/* 
 * File:   Button.cpp
 * Author: Erwin
 * 
 * Created on 21 juni 2010, 16:32
 */

#include "Button.h"

void Button::setListener(ButtonListener * lst) {
    this->bl = lst;
}

unsigned char Button::buttonDown() {
    if(mkt_kbd_is_pressed(mtk_key)) {
     	int lastState = this->state;
        this->state = DOWN;        	
        return lastState == UP;
    }
    return 0;
}

unsigned char Button::buttonUp() {
    if(!mkt_kbd_is_pressed(mtk_key)) {
    	int lastState = this->state;
        this->state = UP;
        return lastState == DOWN;
    }   
    return 0;
}

unsigned char Button::getState() {
    return state;
}

void Button::setButton(mkt_key_enum key){
    this->mtk_key = key;
    this->state = UP;
}

ButtonListener * Button::getListener() {
	return this->bl;
}
